import requests
import unittest
import config
import json

from api.apido import ApiDo
from lib.writexhxtoken import WriteXhxToken


class ApiDo_Test(unittest.TestCase):
    def setUp(self):
        self.session = requests.session()

    def tearDown(self):
        self.session.close()

    def test_01_apido(self):
        WriteXhxToken().update_web_token_in_json(2)
        token = config.load_config()["token"]
        data = {
            "token": token,
            "service_name": "classprod.PerformancePkQueryFacade.listPerformanceLecturer",
            "client_id": "6",
            "strategy": "dubbo",
            "timestamp": 1732695204809,
            "param": {
                "gradeId": 8
            }
        }
        respone = ApiDo().apiDo(self.session, data)
        respones = respone.json()
        formatted_json = json.dumps(respones, indent=2, ensure_ascii=False)
        print(formatted_json)

